home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / tsipp / tsipp.lha / tsipp3.0a / tests / obj.test < prev    next >
Encoding:
Text File  |  1992-11-02  |  11.7 KB  |  531 lines

  1. #==============================================================================
  2. #                                  obj.test
  3. #------------------------------------------------------------------------------
  4. # Test of the Tcl SIPP object commands.
  5. #------------------------------------------------------------------------------
  6. # Copyright 1992 Mark Diekhans
  7. # Permission to use, copy, modify, and distribute this software and its
  8. # documentation for any purpose and without fee is hereby granted, provided
  9. # that the above copyright notice appear in all copies.  Mark Diekhans makes
  10. # no representations about the suitability of this software for any purpose.
  11. # It is provided "as is" without express or implied warranty.
  12. #------------------------------------------------------------------------------
  13. # $Id: obj.test,v 2.0 1992/11/02 03:55:56 markd Rel $
  14. #==============================================================================
  15.  
  16. if {[info procs test] == ""} {source testprocs.tcl}
  17.  
  18. #
  19. # Returns a list of two surfaces.
  20. #
  21. proc Cube {} {
  22.     set shader [SippShaderBasic .6 .1 .4 {.8 .5 .2}]
  23.     SippPolygonPush {{-1  1  1} { 1  1  1} { 1  1 -1} {-1  1 -1}}
  24.     SippPolygonPush {{-1 -1 -1} { 1 -1 -1} { 1 -1  1} {-1 -1  1}}
  25.     SippPolygonPush {{-1  1  1} {-1 -1  1} { 1 -1  1} { 1  1  1}}
  26.     lappend surfaceList [SippSurfaceCreate $shader] 
  27.     SippShaderDelete $shader
  28.    
  29.     set shader [SippShaderBasic .6 .1 .4 {.8 .2 .5}]
  30.     SippPolygonPush {{ 1  1  1} { 1 -1  1} { 1 -1 -1} { 1  1 -1}}
  31.     SippPolygonPush {{ 1  1 -1} { 1 -1 -1} {-1 -1 -1} {-1  1 -1}}
  32.     SippPolygonPush {{-1  1 -1} {-1 -1 -1} {-1 -1  1} {-1  1  1}}
  33.     lappend surfaceList [SippSurfaceCreate $shader] 
  34.     SippShaderDelete $shader
  35.  
  36.     return $surfaceList
  37. }
  38.  
  39. #
  40. # Creates an object with the Cube surfaces
  41. #
  42. proc CubeObj {} {
  43.     set surfList [Cube]
  44.     set objHdl [SippObjectCreate]
  45.     SippObjectAddSurface $objHdl $surfList
  46.     SippSurfaceDelete $surfList
  47.     return $objHdl
  48. }
  49.  
  50. #
  51. # Test SippObjectCreate command.
  52. #
  53.  
  54. test {object-1.1} {
  55.     SippObjectCreate  XXX
  56. } 1 {wrong # args: SippObjectCreate}
  57.  
  58. test {object-1.2} {
  59.     set object1 [SippObjectCreate]
  60.     set object2 [SippObjectCreate]
  61.     list [crange $object1 0 5] [crange $object2 0 5] \
  62.          [expr {"$object1"=="$object2"}]
  63. } 0 {object object 0}
  64.  
  65. #
  66. # Test SippObjectDelete command.
  67. #
  68.  
  69. test {object-2.1} {
  70.     SippObjectDelete XXX
  71. } 1 {invalid object handle: XXX}
  72.  
  73. test {object-2.2} {
  74.     SippObjectDelete
  75. } 1 {wrong # args: SippObjectDelete objectlist}
  76.  
  77. test {object-2.3} {
  78.     set objList {}
  79.     for {set idx  0} {$idx < 75} {incr idx} {
  80.         lappend objList [SippObjectCreate]
  81.     }
  82.     SippObjectDelete $objList
  83. } 0 {}
  84.  
  85. #
  86. # Test SippObjectInstance command.
  87. #
  88.  
  89. test {object-3.1} {
  90.     SippObjectInstance XXX
  91. } 1 {invalid object handle: XXX}
  92.  
  93. test {object-3.2} {
  94.     SippObjectInstance
  95. } 1 {wrong # args: SippObjectInstance objecthandle}
  96.  
  97. test {object-3.3} {
  98.     catch {unset objectx1}; catch {unset objectx2}
  99.     set objectx1 [CubeObj]
  100.     set objectx2 [SippObjectInstance $objectx1]
  101.     SippObjectDelete [list $objectx1 $objectx2]
  102.     crange $objectx2 0 5
  103. } 0 {object}
  104.  
  105. #
  106. # Test SippObjectDup command.
  107. #
  108.  
  109. test {object-4.1} {
  110.     SippObjectDup XXX
  111. } 1 {invalid object handle: XXX}
  112.  
  113. test {object-4.2} {
  114.     SippObjectDup
  115. } 1 {wrong # args: SippObjectDup objecthandle}
  116.  
  117. test {object-4.3} {
  118.     catch {unset objectx1}; catch {unset objectx2}
  119.     set objectx1 [CubeObj]
  120.     set objectx2 [SippObjectDup $objectx1]
  121.     SippObjectDelete [list $objectx1 $objectx2]
  122.     crange $objectx2 0 5
  123. } 0 {object}
  124.  
  125. #
  126. # Test SippObjectDeepDup command.
  127. #
  128.  
  129. test {object-5.1} {
  130.     SippObjectDeepDup XXX
  131. } 1 {invalid object handle: XXX}
  132.  
  133. test {object-5.2} {
  134.     SippObjectDeepDup
  135. } 1 {wrong # args: SippObjectDeepDup objecthandle}
  136.  
  137. test {object-5.3} {
  138.     catch {unset objectx1}; catch {unset objectx2}
  139.     set objectx1 [CubeObj]
  140.     set objectx2 [SippObjectDeepDup $objectx1]
  141.     SippObjectDelete [list $objectx1 $objectx2]
  142.     crange $objectx2 0 5
  143. } 0 {object}
  144.  
  145. #
  146. # Test SippObjectClearTransf command.
  147. #
  148.  
  149. test {object-6.1} {
  150.     SippObjectClearTransf XXX
  151. } 1 {invalid object handle: XXX}
  152.  
  153. test {object-6.2} {
  154.     SippObjectClearTransf
  155. } 1 {wrong # args: SippObjectClearTransf objectlist}
  156.  
  157. test {object-6.3} {
  158.     SippObjectSetTransf $object1 $testMat2
  159.     SippObjectClearTransf $object1
  160.     SippObjectGetTransf $object1
  161. } 0 $identityMat
  162.  
  163. #
  164. # Test SippObjectGetTransf commands.
  165. #
  166.  
  167. test {object-7.1} {
  168.     SippObjectGetTransf XXX
  169. } 1 {invalid object handle: XXX}
  170.  
  171. test {object-7.2} {
  172.     SippObjectGetTransf
  173. } 1 {wrong # args: SippObjectGetTransf objecthandle}
  174.  
  175. test {object-7.3} {
  176.     SippObjectClearTransf $object1
  177.     SippObjectGetTransf $object1
  178. } 0 $identityMat
  179.  
  180. test {object-7.4} {
  181.     SippObjectClearTransf $object1
  182.     SippObjectSetTransf $object1 $testMat1
  183.     SippObjectGetTransf $object1
  184. } 0 $testMat1
  185.  
  186.  
  187. #
  188. # Test SippObjectSetTransf command
  189. #
  190.  
  191. test {object-8.1} {
  192.     SippObjectSetTransf  YYY $testMat1
  193. } 1 {invalid object handle: YYY}
  194.  
  195. test {object-8.2} {
  196.     SippObjectSetTransf
  197. } 1 {wrong # args: SippObjectSetTransf objectlist matrix}
  198.  
  199. test {object-8.3} {
  200.     SippObjectClearTransf $object1
  201.     SippObjectSetTransf $object1 $testMat1
  202.     SippObjectSetTransf $object1 $testMat2
  203.     SippObjectGetTransf $object1
  204. } 0 $testMat2
  205.  
  206. #
  207. # Test SippObjectTransform command.
  208. #
  209.  
  210. test {object-9.1} {
  211.     SippObjectTransform XXX $testMat1
  212. } 1 {invalid object handle: XXX}
  213.  
  214. test {object-9.2} {
  215.     SippObjectTransform
  216. } 1 {wrong # args: SippObjectTransform objectlist matrix}
  217.  
  218. test {object-9.3} {
  219.     SippObjectClearTransf $object1
  220.     SippObjectTransform $object1 $testMat1
  221.     SippObjectGetTransf $object1
  222. } 0 $testMat1
  223.  
  224. #
  225. # Test SippObjectAddSurface command.
  226. #
  227.  
  228. test {object-10.1} {
  229.     SippObjectAddSurface XXX YYY
  230. } 1 {invalid object handle: XXX}
  231.  
  232. test {object-10.2} {
  233.     SippObjectAddSurface
  234. } 1 {wrong # args: SippObjectAddSurface objecthandle surfacelist}
  235.  
  236. test {object-10.3} {
  237.     SippObjectAddSurface $object1 surfacex
  238. } 1 {invalid surface handle: surfacex}
  239.  
  240. test {object-10.4} {
  241.     set surfList [Cube]
  242.     SippObjectAddSurface $object1 $surfList
  243.     SippSurfaceDelete $surfList
  244. } 0 {}
  245.  
  246. #
  247. # Test SippObjectSubSurface commands.
  248. #
  249.  
  250. test {object-11.1} {
  251.     SippObjectSubSurface XXX YYY
  252. } 1 {invalid object handle: XXX}
  253.  
  254. test {object-11.2} {
  255.     SippObjectSubSurface
  256. } 1 {wrong # args: SippObjectSubSurface objecthandle surfacelist}
  257.  
  258. test {object-11.3} {
  259.     SippObjectSubSurface $object1 surfacex
  260. } 1 {invalid surface handle: surfacex}
  261.  
  262. test {object-11.4} {
  263.     set surfList [Cube]
  264.     SippObjectAddSurface $object1 $surfList
  265.     SippObjectSubSurface $object1 $surfList
  266.     SippSurfaceDelete $surfList
  267. } 0 {}
  268.  
  269. #
  270. # Test SippObjectAddSubobj command.
  271. #
  272.  
  273. test {object-12.1} {
  274.     SippObjectAddSubobj XXX YYY
  275. } 1 {invalid object handle: XXX}
  276.  
  277. test {object-12.2} {
  278.     SippObjectAddSubobj
  279. } 1 {wrong # args: SippObjectAddSubobj objecthandle subobjlist}
  280.  
  281. test {object-12.3} {
  282.     SippObjectAddSubobj $object1 objectx
  283. } 1 {invalid object handle: objectx}
  284.  
  285. test {object-12.4} {
  286.     set object2 [CubeObj]
  287.     SippObjectAddSubobj $object1 $object2
  288.     SippObjectDelete $object2
  289. } 0 {}
  290.  
  291. test {object-12.5} {
  292.     set object2 [CubeObj]
  293.     set object3 [CubeObj]
  294.     SippObjectAddSubobj $object1 [list $object2 $object3]
  295.     SippObjectDelete [list $object2 $object3]
  296. } 0 {}
  297.  
  298. #
  299. # Test SippObjectSubSubobj command.
  300. #
  301.  
  302. test {object-13.1} {
  303.     SippObjectSubSubobj XXX YYY
  304. } 1 {invalid object handle: XXX}
  305.  
  306. test {object-13.2} {
  307.     SippObjectSubSubobj
  308. } 1 {wrong # args: SippObjectSubSubobj objecthandle subobjlist}
  309.  
  310. test {object-13.3} {
  311.     SippObjectSubSubobj $object1 objectx
  312. } 1 {invalid object handle: objectx}
  313.  
  314. test {object-13.4} {
  315.     set object2 [CubeObj]
  316.     SippObjectAddSubobj $object1 $object2
  317.     SippObjectSubSubobj $object1 $object2
  318.     SippObjectDelete $object2
  319. } 0 {}
  320.  
  321. test {object-13.5} {
  322.     set object2 [CubeObj]
  323.     set object3 [CubeObj]
  324.     SippObjectAddSubobj $object1 [list $object2 $object3]
  325.     SippObjectSubSubobj $object1 [list $object2 $object3]
  326.     SippObjectDelete [list $object2 $object3]
  327. } 0 {}
  328.  
  329. #
  330. # Test SippObjectRotateX command.
  331. #
  332.  
  333. test {object-14.1} {
  334.     SippObjectRotateX XXX 1
  335. } 1 {invalid object handle: XXX}
  336.  
  337. test {object-14.2} {
  338.     SippObjectRotateX
  339. } 1 {wrong # args: SippObjectRotateX object angle}
  340.  
  341. test {object-14.3} {
  342.     SippObjectRotateX $object1 aa
  343. } 1 {expected floating-point number but got "aa"}
  344.  
  345. test {object-14.4} {
  346.     SippObjectRotateX $object1 10
  347. } 0 {}
  348.  
  349. test {object-14.5} {
  350.     SippObjectRotateX $object1 R10
  351. } 0 {}
  352.  
  353. test {object-14.6} {
  354.     SippObjectRotateX $object1 D10
  355. } 0 {}
  356.  
  357. #
  358. # Test SippObjectRotateX command.
  359. #
  360.  
  361. test {object-15.1} {
  362.     SippObjectRotateX XXX 1
  363. } 1 {invalid object handle: XXX}
  364.  
  365. test {object-15.2} {
  366.     SippObjectRotateX
  367. } 1 {wrong # args: SippObjectRotateX object angle}
  368.  
  369. test {object-15.3} {
  370.     SippObjectRotateX $object1 aa
  371. } 1 {expected floating-point number but got "aa"}
  372.  
  373. test {object-15.4} {
  374.     SippObjectRotateX $object1 10
  375. } 0 {}
  376.  
  377. test {object-15.5} {
  378.     SippObjectRotateX $object1 R10
  379. } 0 {}
  380.  
  381. test {object-15.6} {
  382.     SippObjectRotateX $object1 D10
  383. } 0 {}
  384.  
  385. #
  386. # Test SippObjectRotateY command.
  387. #
  388.  
  389. test {object-16.1} {
  390.     SippObjectRotateY XXX 1
  391. } 1 {invalid object handle: XXX}
  392.  
  393. test {object-16.2} {
  394.     SippObjectRotateY
  395. } 1 {wrong # args: SippObjectRotateY object angle}
  396.  
  397. test {object-16.3} {
  398.     SippObjectRotateY $object1 aa
  399. } 1 {expected floating-point number but got "aa"}
  400.  
  401. test {object-16.4} {
  402.     SippObjectRotateY $object1 10
  403. } 0 {}
  404.  
  405. test {object-16.5} {
  406.     SippObjectRotateY $object1 R10
  407. } 0 {}
  408.  
  409. test {object-16.6} {
  410.     SippObjectRotateY $object1 D10
  411. } 0 {}
  412.  
  413. #
  414. # Test SippObjectRotateZ command.
  415. #
  416.  
  417. test {object-17.1} {
  418.     SippObjectRotateZ XXX 1
  419. } 1 {invalid object handle: XXX}
  420.  
  421. test {object-17.2} {
  422.     SippObjectRotateZ
  423. } 1 {wrong # args: SippObjectRotateZ object angle}
  424.  
  425. test {object-17.3} {
  426.     SippObjectRotateZ $object1 aa
  427. } 1 {expected floating-point number but got "aa"}
  428.  
  429. test {object-17.4} {
  430.     SippObjectRotateZ $object1 10
  431. } 0 {}
  432.  
  433. test {object-17.5} {
  434.     SippObjectRotateZ $object1 R10
  435. } 0 {}
  436.  
  437. test {object-17.6} {
  438.     SippObjectRotateZ $object1 D10
  439. } 0 {}
  440.  
  441.  
  442. #
  443. # Test SippObjectRotate command.
  444. #
  445.  
  446. test {object-18.1} {
  447.     SippObjectRotate XXX {1.1 2.2 3.3} {1.1 0.0 1.2} R10
  448. } 1 {invalid object handle: XXX}
  449.  
  450. test {object-18.2} {
  451.     SippObjectRotate
  452. } 1 {wrong # args: SippObjectRotate objecthandle point vector angle}
  453.  
  454. test {object-18.3} {
  455.     SippObjectRotate $object1 {1.x 2.2 3.3} {1.1 0.0 1.2} R10
  456. } 1 {expected floating-point number but got "1.x"}
  457.  
  458. test {object-18.4} {
  459.     SippObjectRotate $object1 {1.0 2.2 3.3} {1.1 0.0 1.2} X10
  460. } 1 {expected floating-point number but got "X10"}
  461.  
  462. test {object-18.5} {
  463.     SippObjectRotate $object1 {1.1 2.2 3.3} {1.1 x.x 1.2} R10
  464. } 1 {expected floating-point number but got "x.x"}
  465.  
  466. test {object-18.6} {
  467.     SippObjectRotate $object1 {1.1 2.2 3.3} {1.1 0.0 1.2} R10
  468. } 0 {}
  469.  
  470. test {object-18.7} {
  471.     SippObjectRotate $object1 {1.1 2.2 3.3} {1.1 0.0 1.2} D100
  472. } 0 {}
  473.  
  474. test {object-18.8} {
  475.     SippObjectRotate $object1 {1.1 2.2 3.3} {1.1 0.0 1.2} 98
  476. } 0 {}
  477.  
  478. #
  479. # Test SippObjectScale command.
  480. #
  481.  
  482. test {object-19.1} {
  483.     SippObjectScale XXX 10
  484. } 1 {invalid object handle: XXX}
  485.  
  486. test {object-19.2} {
  487.     SippObjectScale
  488. } 1 {wrong # args: SippObjectScale objecthandle factor|{xfactor yfactor zfactor}}
  489.  
  490. test {object-19.3} {
  491.     SippObjectScale $object1 1x
  492. } 1 {expected floating-point number but got "1x"}
  493.  
  494. test {object-19.4} {
  495.     SippObjectScale $object1 10
  496. } 0 {}
  497.  
  498. #
  499. # Test SippObjectMove command.
  500. #
  501.  
  502. test {object-20.1} {
  503.     SippObjectMove XXX {1 2 3}
  504. } 1 {invalid object handle: XXX}
  505.  
  506. test {object-20.2} {
  507.     SippObjectMove
  508. } 1 {wrong # args: SippObjectMove objecthandle {xdist ydist zdist}}
  509.  
  510. test {object-20.3} {
  511.     SippObjectMove $object1 {1 x 3}
  512. } 1 {expected floating-point number but got "x"}
  513.  
  514. test {object-20.4} {
  515.     SippObjectMove $object1 {1 2 3}
  516. } 0 {}
  517.  
  518. #
  519. # Clean up...
  520. #
  521.  
  522. test {object-21.1} {
  523.     SippObjectDelete $object1
  524. } 0 {}
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.